import requests
from apiAutomation import app
from apiAutomation.api.login import LoginApi


class TelApi:
    def __init__(self, token):
        # 添加客服电话url
        self.add_tel_url = app.BATH_URL + "/cabinet/addTelephone"
        # 查询客服电话url
        self.query_tel_url = app.BATH_URL + "/cabinet/queryTelephone"
        # 修改客服电话url
        self.update_tel_url = app.BATH_URL + "/user/update"
        # 请求头
        # 请求头
        self.headers_dict = {
            "content-type": "applocation/json",
            "token": token
        }

    # 添加客服电话接口
    def add_tel(self):
        data = {
            "telephoen": "1321232522"
        }
        print(self.headers_dict)
        return requests.post(url=self.add_tel_url, headers=self.headers_dict, json=data)

    # 修改客服电话接口
    def update_tel(self):
        data = {
            "id": 15,
            "username": "hdg",
            "password": "321"
        }
        return requests.post(url=self.update_tel_url, headers=self.headers_dict, json=data)

    # 查询客服电话接口
    def query_tel(self):
        return requests.get(url=self.query_tel_url, headers=self.headers_dict)


if __name__ == '__main__':
    a = LoginApi()
    token = a.get_token()
    print(token)
    print(TelApi(token).update_tel().text)
